package com.example.lenovo.manager;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.avos.avoscloud.AVOSCloud;

public class IndexPage extends AppCompatActivity {

    private RadioGroup radioGroup;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_index_page);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);


        radioGroup = (RadioGroup) findViewById(R.id.Group);
        radioGroup.setOnCheckedChangeListener(new RadioGroupCheckedChangeLisitener());


    }

    /**
     * RadioGroup监听器
     */
    public class RadioGroupCheckedChangeLisitener implements RadioGroup.OnCheckedChangeListener{
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            switch (checkedId){
                case R.id.FirstButton:{
                    System.out.println('\n'+"1"+'\n');

                    Manager manager = new Manager();
                    System.out.println("01");
                    FragmentManager fragmentManager = getFragmentManager();
                    System.out.println("02");
                    FragmentTransaction beginTransaction = fragmentManager.beginTransaction();
                    System.out.println("03");
                    beginTransaction.replace(R.id.FrameOut, manager);
                    System.out.println("04");
                    beginTransaction.commit();
                    System.out.println("05");


                    break;
                }
                case R.id.SecondButton:{
                    System.out.println('\n' + "2" + '\n');

                    Product product = new Product();
                    System.out.println("01");
                    FragmentManager fragmentManager = getFragmentManager();
                    System.out.println("02");
                    FragmentTransaction beginTransaction = fragmentManager.beginTransaction();
                    System.out.println("03");
                    beginTransaction.replace(R.id.FrameOut, product);
                    System.out.println("04");
                    beginTransaction.commit();
                    System.out.println("05");

                    break;
                }
                case R.id.ThirdButton:{
                    System.out.println('\n' + "2" + '\n');

                    ProductDelete productDelete = new ProductDelete();
                    System.out.println("01");
                    FragmentManager fragmentManager = getFragmentManager();
                    System.out.println("02");
                    FragmentTransaction beginTransaction = fragmentManager.beginTransaction();
                    System.out.println("03");
                    beginTransaction.replace(R.id.FrameOut, productDelete);
                    System.out.println("04");
                    beginTransaction.commit();
                    System.out.println("05");

                    break;
                }
            }
        }
    }

}
